package com.lyc.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyc.dao.AddressDao;
import com.lyc.pojo.Address;
import com.lyc.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
@Service("addressService")
public class AddressServiceImpl implements AddressService {
   @Autowired
    private AddressDao addressDao;

    public List<Address> addAddress(Address address) {

        addressDao.addAddress(address);
        return selectAddress(address.getUid());
    }

    @Override
    public List<Address> updateAddress(Address address) {
         addressDao.updateAddress(address);
        return selectAddress(address.getUid());
    }

    @Override
    public List<Address> deleteAddress( Integer aid,Integer uid) {

        addressDao.deleteAddress(aid);
        return selectAddress(uid);
    }

    @Override
    public List<Address> selectAddress(Integer uid) {
        return addressDao.selectAddress(uid);
    }

    @Override
    public Address selectOne(Integer aid) {
        return addressDao.selectone(aid);
    }
    /*后台代码*/

    @Override
    public PageInfo<Address> getAddressByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Address> addresses=addressDao.selectAll();
        return new PageInfo<>(addresses);
    }

    @Override
    public List<Address> selectAll() {
        return null;
    }
}
